package com.tbit.uqbike.service.business.tag;

import com.tbit.uqbike.enums.TagStatus;
import com.tbit.uqbike.object.pojo.tag.Tag;
import com.tbit.uqbike.object.pojo.vo.BatchOperationMsgVO;
import com.tbit.common.entity.view.PageResult;
import com.tbit.uqbike.service.business.tag.validation.group.tag.CreateTagGroup;
import com.tbit.uqbike.service.business.tag.validation.group.tag.DeleteTagGroup;
import com.tbit.uqbike.service.business.tag.validation.group.tag.UpdateTagGroup;
import com.tbit.uqbike.webmanager.dto.TagDTO;
import com.tbit.uqbike.webmanager.req.tag.QueryTagListReq;
import com.tbit.uqbike.webmanager.resp.tag.TagBaseInfo;
import com.tbit.uqbike.webmanager.resp.tag.TagResp;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;

/**
 * 标签服务
 *
 *
 * @author <a href="mailto:chen.chaoxiong@tbit.com.cn">ChenChaoXiong</a>
 * @since 2024/7/8
 */
@Validated
public interface TagService {

    /**
     * 创建标签
     *
     * @param tag
     * @return
     */
    @Validated(CreateTagGroup.class)
    Long createTag(TagDTO tag) throws TagNameAlreadyExistsException;

    /**
     * 更新标签
     *
     * @param tag
     * @return
     */
    @Validated(UpdateTagGroup.class)
    Boolean updateTag(@Valid TagDTO tag) throws TagNameAlreadyExistsException,TagNotFoundException;

    /**
     * 删除标签
     * 根据id删除标签
     * @param tags
     * @return
     */
    @Validated(DeleteTagGroup.class)
    BatchOperationMsgVO<String> deleteTagBatch(@Valid @NotEmpty List<TagDTO> tags);

    /**
     * 批量启用标签
     * @param tags
     * @return
     */
    @Validated(UpdateTagGroup.class)
    BatchOperationMsgVO<String> enableBatch(@Valid @NotEmpty List<TagDTO> tags);

    /**
     * 批量禁用标签
     * @param tags
     * @return
     */
    @Validated(UpdateTagGroup.class)
    BatchOperationMsgVO<String> disableBatch(@Valid @NotEmpty List<TagDTO> tags);

    /**
     * 查询标签列表
     * not null
     * @param brandId
     * @param tagStatus 当tagStatus为null时，查询所有标签
     * @see TagStatus
     * @return
     */
    @NotNull
    List<TagBaseInfo> list(@Valid @NotNull Integer brandId, TagStatus tagStatus);

    /**
     * 分页查询标签列表
     * not null
     * @param req  page: 页码，默认1, rowCount: 每页条数，默认10
     * @return
     */
    @NotNull
    PageResult<List<TagResp>> listPage(@Valid QueryTagListReq req);

    /**
     * 取出集合中无效的标签ID(不存在于数据库或者不处于启用状态)
     * @param tagIds
     * @return
     */
    @NotNull
    Set<Long> extractEnableTagIds(@Valid @NotEmpty Set<Long> tagIds);

    /**
     * 删除标签
     * @param tag
     * @return
     */
    @Validated(DeleteTagGroup.class)
    Boolean deleteTag(@Valid TagDTO tag);

    /**
     * 禁用标签
     * @param tag
     * @return
     */
    @Validated(UpdateTagGroup.class)
    Boolean disableTag(@Valid TagDTO tag);


    List<Tag> getTags(Integer machineId);
}
